package academic.emailClient.control.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import academic.emailClient.EmailClientImpl;
import academic.emailClient.model.EmailClientModel;
import academic.emailClient.view.EmailClientViewInterface;

public class CreateNewMeetingButtonActionListener  implements ActionListener{	
	private EmailClientViewInterface view;
	private EmailClientModel model;
	
/**
 * constructor
 * 	
 * @param view
 * @param model
 */
	public CreateNewMeetingButtonActionListener(EmailClientViewInterface view, EmailClientModel model){
		super();
		this.view = view;
		this.model = model;
	}

	/**
	 * handle create new meeting button action event
	 */
	@Override
	public void actionPerformed(ActionEvent e) {	
		if(!view.areFieldsEmpty()){
			 if (view.checkIfDateIsFuture()){
				 model.createMeeting(view.getMeeting());
				 view.displayMeetingCreationSuccessMessage();	
			 }
			 else{
				 // Date is a past date
				 view.displayMeetingPastDayEnteredMessage(view.getMeeting());	
			 }
		}
		else{
			// Not all fields are entered
			view.displayMeetingCreationFailureMessage();
		}
		
	}
}

